package com._520it.crm.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com._520it.crm.domain.Role;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.QueryObject;
import com._520it.crm.service.IRoleService;
import com._520it.crm.util.JsonResult;

@Controller
public class RoleController {
	
	@Autowired
	private IRoleService service;
	
	@RequestMapping("/role")
	public String index(){
		return "role";
	}

	@RequestMapping("/role_save")
	@ResponseBody
	public JsonResult save(Role role){
		JsonResult result = new JsonResult();
		try{
			service.insert(role);
			result.setSuccess(true);
			result.setMsg("保存成功！");
		}catch (Exception e) {
			//记录日志
			result.setSuccess(false);
			result.setMsg("保存失败！");
		}
		return result;
	}
	
	@RequestMapping("/role_list")
	@ResponseBody
	public PageResult list(QueryObject qo){
		return service.queryPageResult(qo);
	}



	
}
